<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: RailsFCGIHandler</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">RailsFCGIHandler</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/rails/railties/lib/fcgi_handler_rb.html">
                vendor/rails/railties/lib/fcgi_handler.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000050">close_connection</a>&nbsp;&nbsp;
      <a href="#M000036">dispatcher_error</a>&nbsp;&nbsp;
      <a href="#M000035">dispatcher_log</a>&nbsp;&nbsp;
      <a href="#M000041">exit_handler</a>&nbsp;&nbsp;
      <a href="#M000040">exit_now_handler</a>&nbsp;&nbsp;
      <a href="#M000049">gc_countdown</a>&nbsp;&nbsp;
      <a href="#M000038">install_signal_handler</a>&nbsp;&nbsp;
      <a href="#M000037">install_signal_handlers</a>&nbsp;&nbsp;
      <a href="#M000034">logger</a>&nbsp;&nbsp;
      <a href="#M000046">mark_features!</a>&nbsp;&nbsp;
      <a href="#M000030">new</a>&nbsp;&nbsp;
      <a href="#M000031">process!</a>&nbsp;&nbsp;
      <a href="#M000029">process!</a>&nbsp;&nbsp;
      <a href="#M000032">process_each_request</a>&nbsp;&nbsp;
      <a href="#M000033">process_request</a>&nbsp;&nbsp;
      <a href="#M000045">reload!</a>&nbsp;&nbsp;
      <a href="#M000042">reload_handler</a>&nbsp;&nbsp;
      <a href="#M000044">restart!</a>&nbsp;&nbsp;
      <a href="#M000043">restart_handler</a>&nbsp;&nbsp;
      <a href="#M000047">restore!</a>&nbsp;&nbsp;
      <a href="#M000048">run_gc!</a>&nbsp;&nbsp;
      <a href="#M000039">with_signal_handler</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">SIGNALS</td>
          <td>=</td>
          <td class="context-item-value">{     'HUP'     =&gt; :reload,     'INT'     =&gt; :exit_now,     'TERM'    =&gt; :exit_now,     'USR1'    =&gt; :exit,     'USR2'    =&gt; :restart</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">GLOBAL_SIGNALS</td>
          <td>=</td>
          <td class="context-item-value">SIGNALS.keys - %w(USR1)</td>
        </tr>
        </table>
      </div>
    </div>



    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">gc_request_period</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">log_file_path</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">when_ready</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000030" class="method-detail">
        <a name="M000030"></a>

        <div class="method-heading">
          <a href="#M000030" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(log_file_path = nil, gc_request_period = nil) {|self if block_given?| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Initialize the FastCGI instance with the path to a crash log detailing
unhandled exceptions (default RAILS_ROOT/log/fastcgi.crash.log) and the
number of requests to process between garbage collection runs (default nil
for normal GC behavior.) Optionally, pass a block which takes this instance
as an argument for further configuration.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000030-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 32</span>
32:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">log_file_path</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">gc_request_period</span> = <span class="ruby-keyword kw">nil</span>)
33:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">log_file_path</span> = <span class="ruby-identifier">log_file_path</span> <span class="ruby-operator">||</span> <span class="ruby-node">&quot;#{RAILS_ROOT}/log/fastcgi.crash.log&quot;</span>
34:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gc_request_period</span> = <span class="ruby-identifier">gc_request_period</span>
35: 
36:     <span class="ruby-comment cmt"># Yield for additional configuration.</span>
37:     <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
38: 
39:     <span class="ruby-comment cmt"># Safely install signal handlers.</span>
40:     <span class="ruby-identifier">install_signal_handlers</span>
41: 
42:     <span class="ruby-comment cmt"># Start error timestamp at 11 seconds ago.</span>
43:     <span class="ruby-ivar">@last_error_on</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-value">11</span>
44:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000029" class="method-detail">
        <a name="M000029"></a>

        <div class="method-heading">
          <a href="#M000029" class="method-signature">
          <span class="method-name">process!</span><span class="method-args">(*args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Initialize and run the FastCGI instance, passing arguments through to <a
href="RailsFCGIHandler.html#M000030">new</a>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000029-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 23</span>
23:   <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">process!</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
24:     <span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>).<span class="ruby-identifier">process!</span>
25:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">
          <a href="#M000031" class="method-signature">
          <span class="method-name">process!</span><span class="method-args">(provider = FCGI)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000031-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 46</span>
46:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process!</span>(<span class="ruby-identifier">provider</span> = <span class="ruby-constant">FCGI</span>)
47:     <span class="ruby-identifier">mark_features!</span>
48: 
49:     <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">'starting'</span>
50:     <span class="ruby-identifier">process_each_request</span> <span class="ruby-identifier">provider</span>
51:     <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">'stopping gracefully'</span>
52: 
53:   <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">error</span>
54:     <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">error</span>
55:     <span class="ruby-keyword kw">when</span> <span class="ruby-constant">SystemExit</span>
56:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">'stopping after explicit exit'</span>
57:     <span class="ruby-keyword kw">when</span> <span class="ruby-constant">SignalException</span>
58:       <span class="ruby-identifier">dispatcher_error</span> <span class="ruby-identifier">error</span>, <span class="ruby-value str">'stopping after unhandled signal'</span>
59:     <span class="ruby-keyword kw">else</span>
60:       <span class="ruby-comment cmt"># Retry if exceptions occur more than 10 seconds apart.</span>
61:       <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@last_error_on</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">10</span>
62:         <span class="ruby-ivar">@last_error_on</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
63:         <span class="ruby-identifier">dispatcher_error</span> <span class="ruby-identifier">error</span>, <span class="ruby-value str">'retrying after unhandled exception'</span>
64:         <span class="ruby-keyword kw">retry</span>
65:       <span class="ruby-keyword kw">else</span>
66:         <span class="ruby-identifier">dispatcher_error</span> <span class="ruby-identifier">error</span>, <span class="ruby-value str">'stopping after unhandled exception within 10 seconds of the last'</span>
67:       <span class="ruby-keyword kw">end</span>
68:     <span class="ruby-keyword kw">end</span>
69:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000050" class="method-detail">
        <a name="M000050"></a>

        <div class="method-heading">
          <a href="#M000050" class="method-signature">
          <span class="method-name">close_connection</span><span class="method-args">(cgi)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000050-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 220</span>
220:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close_connection</span>(<span class="ruby-identifier">cgi</span>)
221:       <span class="ruby-identifier">cgi</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-value str">&quot;@request&quot;</span>).<span class="ruby-identifier">finish</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cgi</span>
222:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="#M000036" class="method-signature">
          <span class="method-name">dispatcher_error</span><span class="method-args">(e, msg = &quot;&quot;)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 122</span>
122:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dispatcher_error</span>(<span class="ruby-identifier">e</span>, <span class="ruby-identifier">msg</span> = <span class="ruby-value str">&quot;&quot;</span>)
123:       <span class="ruby-identifier">error_message</span> =
124:         <span class="ruby-node">&quot;Dispatcher failed to catch: #{e} (#{e.class})\n&quot;</span> <span class="ruby-operator">+</span>
125:         <span class="ruby-node">&quot;  #{e.backtrace.join(&quot;\n  &quot;)}\n#{msg}&quot;</span>
126:       <span class="ruby-identifier">dispatcher_log</span>(<span class="ruby-identifier">:error</span>, <span class="ruby-identifier">error_message</span>)
127:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">dispatcher_log</span><span class="method-args">(level, msg)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 114</span>
114:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dispatcher_log</span>(<span class="ruby-identifier">level</span>, <span class="ruby-identifier">msg</span>)
115:       <span class="ruby-identifier">time_str</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%d/%b/%Y:%H:%M:%S&quot;</span>)
116:       <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">level</span>, <span class="ruby-node">&quot;[#{time_str} :: #{$$}] #{msg}&quot;</span>)
117:     <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">log_error</span>  <span class="ruby-comment cmt"># Logger errors</span>
118:       <span class="ruby-constant">STDERR</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;Couldn't write to #{@log_file_path.inspect}: #{msg}\n&quot;</span>
119:       <span class="ruby-constant">STDERR</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;  #{log_error.class}: #{log_error.message}\n&quot;</span>
120:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="#M000041" class="method-signature">
          <span class="method-name">exit_handler</span><span class="method-args">(signal)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000041-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 159</span>
159:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exit_handler</span>(<span class="ruby-identifier">signal</span>)
160:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">&quot;asked to stop ASAP&quot;</span>
161:       <span class="ruby-ivar">@when_ready</span> = <span class="ruby-identifier">:exit</span>
162:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">exit_now_handler</span><span class="method-args">(signal)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 154</span>
154:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exit_now_handler</span>(<span class="ruby-identifier">signal</span>)
155:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">&quot;asked to stop immediately&quot;</span>
156:       <span class="ruby-identifier">exit</span>
157:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000049" class="method-detail">
        <a name="M000049"></a>

        <div class="method-heading">
          <a href="#M000049" class="method-signature">
          <span class="method-name">gc_countdown</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000049-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 212</span>
212:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">gc_countdown</span>
213:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">gc_request_period</span>
214:         <span class="ruby-ivar">@gc_request_countdown</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">gc_request_period</span>
215:         <span class="ruby-ivar">@gc_request_countdown</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
216:         <span class="ruby-identifier">run_gc!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@gc_request_countdown</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>
217:       <span class="ruby-keyword kw">end</span>
218:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">install_signal_handler</span><span class="method-args">(signal, handler = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 133</span>
133:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">install_signal_handler</span>(<span class="ruby-identifier">signal</span>, <span class="ruby-identifier">handler</span> = <span class="ruby-keyword kw">nil</span>)
134:       <span class="ruby-keyword kw">if</span> <span class="ruby-constant">SIGNALS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">signal</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">method_defined?</span>(<span class="ruby-identifier">name</span> = <span class="ruby-node">&quot;#{SIGNALS[signal]}_handler&quot;</span>)
135:         <span class="ruby-identifier">handler</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">method</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">to_proc</span>
136: 
137:         <span class="ruby-keyword kw">begin</span>
138:           <span class="ruby-identifier">trap</span>(<span class="ruby-identifier">signal</span>, <span class="ruby-identifier">handler</span>)
139:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span>
140:           <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:warn</span>, <span class="ruby-node">&quot;Ignoring unsupported signal #{signal}.&quot;</span>
141:         <span class="ruby-keyword kw">end</span>
142:       <span class="ruby-keyword kw">else</span>
143:         <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:warn</span>, <span class="ruby-node">&quot;Ignoring unsupported signal #{signal}.&quot;</span>
144:       <span class="ruby-keyword kw">end</span>
145:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="#M000037" class="method-signature">
          <span class="method-name">install_signal_handlers</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 129</span>
129:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">install_signal_handlers</span>
130:       <span class="ruby-constant">GLOBAL_SIGNALS</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">signal</span><span class="ruby-operator">|</span> <span class="ruby-identifier">install_signal_handler</span>(<span class="ruby-identifier">signal</span>) }
131:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="#M000034" class="method-signature">
          <span class="method-name">logger</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 110</span>
110:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logger</span>
111:       <span class="ruby-ivar">@logger</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@log_file_path</span>)
112:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000046" class="method-detail">
        <a name="M000046"></a>

        <div class="method-heading">
          <a href="#M000046" class="method-signature">
          <span class="method-name">mark_features!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Make a note of $&quot; so we can safely reload this instance.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000046-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 197</span>
197:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mark_features!</span>
198:       <span class="ruby-ivar">@features</span> = <span class="ruby-identifier">$&quot;</span>.<span class="ruby-identifier">clone</span>
199:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="#M000032" class="method-signature">
          <span class="method-name">process_each_request</span><span class="method-args">(provider)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000032-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 73</span>
73:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_each_request</span>(<span class="ruby-identifier">provider</span>)
74:       <span class="ruby-identifier">cgi</span> = <span class="ruby-keyword kw">nil</span>
75: 
76:       <span class="ruby-identifier">provider</span>.<span class="ruby-identifier">each_cgi</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cgi</span><span class="ruby-operator">|</span>
77:         <span class="ruby-identifier">process_request</span>(<span class="ruby-identifier">cgi</span>)
78: 
79:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">when_ready</span>
80:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:reload</span>
81:             <span class="ruby-identifier">reload!</span>
82:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:restart</span>
83:             <span class="ruby-identifier">close_connection</span>(<span class="ruby-identifier">cgi</span>)
84:             <span class="ruby-identifier">restart!</span>
85:           <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:exit</span>
86:             <span class="ruby-identifier">close_connection</span>(<span class="ruby-identifier">cgi</span>)
87:             <span class="ruby-keyword kw">break</span>
88:         <span class="ruby-keyword kw">end</span>
89:       <span class="ruby-keyword kw">end</span>
90:     <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SignalException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">signal</span>
91:       <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">signal</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'SIGUSR1'</span>
92:       <span class="ruby-identifier">close_connection</span>(<span class="ruby-identifier">cgi</span>)
93:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="#M000033" class="method-signature">
          <span class="method-name">process_request</span><span class="method-args">(cgi)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 95</span>
 95:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_request</span>(<span class="ruby-identifier">cgi</span>)
 96:       <span class="ruby-ivar">@when_ready</span> = <span class="ruby-keyword kw">nil</span>
 97:       <span class="ruby-identifier">gc_countdown</span>
 98: 
 99:       <span class="ruby-identifier">with_signal_handler</span> <span class="ruby-value str">'USR1'</span> <span class="ruby-keyword kw">do</span>
100:         <span class="ruby-keyword kw">begin</span>
101:           <span class="ruby-constant">Dispatcher</span>.<span class="ruby-identifier">dispatch</span>(<span class="ruby-identifier">cgi</span>)
102:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SignalException</span>, <span class="ruby-constant">SystemExit</span>
103:           <span class="ruby-identifier">raise</span>
104:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">error</span>
105:           <span class="ruby-identifier">dispatcher_error</span> <span class="ruby-identifier">error</span>, <span class="ruby-value str">'unhandled dispatch error'</span>
106:         <span class="ruby-keyword kw">end</span>
107:       <span class="ruby-keyword kw">end</span>
108:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000045" class="method-detail">
        <a name="M000045"></a>

        <div class="method-heading">
          <a href="#M000045" class="method-signature">
          <span class="method-name">reload!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000045-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 189</span>
189:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload!</span>
190:       <span class="ruby-identifier">run_gc!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">gc_request_period</span>
191:       <span class="ruby-identifier">restore!</span>
192:       <span class="ruby-ivar">@when_ready</span> = <span class="ruby-keyword kw">nil</span>
193:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">&quot;reloaded&quot;</span>
194:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000042" class="method-detail">
        <a name="M000042"></a>

        <div class="method-heading">
          <a href="#M000042" class="method-signature">
          <span class="method-name">reload_handler</span><span class="method-args">(signal)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000042-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 164</span>
164:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload_handler</span>(<span class="ruby-identifier">signal</span>)
165:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">&quot;asked to reload ASAP&quot;</span>
166:       <span class="ruby-ivar">@when_ready</span> = <span class="ruby-identifier">:reload</span>
167:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000044" class="method-detail">
        <a name="M000044"></a>

        <div class="method-heading">
          <a href="#M000044" class="method-signature">
          <span class="method-name">restart!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000044-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 174</span>
174:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restart!</span>
175:       <span class="ruby-identifier">config</span>       = <span class="ruby-operator">::</span><span class="ruby-constant">Config</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>
176:       <span class="ruby-identifier">ruby</span>         = <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">join</span>(<span class="ruby-identifier">config</span>[<span class="ruby-value str">'bindir'</span>], <span class="ruby-identifier">config</span>[<span class="ruby-value str">'ruby_install_name'</span>]) <span class="ruby-operator">+</span> <span class="ruby-identifier">config</span>[<span class="ruby-value str">'EXEEXT'</span>]
177:       <span class="ruby-identifier">command_line</span> = [<span class="ruby-identifier">ruby</span>, <span class="ruby-identifier">$0</span>, <span class="ruby-constant">ARGV</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
178: 
179:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">&quot;restarted&quot;</span>
180: 
181:       <span class="ruby-comment cmt"># close resources as they won't be closed by</span>
182:       <span class="ruby-comment cmt"># the OS when using exec</span>
183:       <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
184:       <span class="ruby-constant">RAILS_DEFAULT_LOGGER</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
185: 
186:       <span class="ruby-identifier">exec</span>(<span class="ruby-identifier">command_line</span>)
187:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000043" class="method-detail">
        <a name="M000043"></a>

        <div class="method-heading">
          <a href="#M000043" class="method-signature">
          <span class="method-name">restart_handler</span><span class="method-args">(signal)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000043-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 169</span>
169:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restart_handler</span>(<span class="ruby-identifier">signal</span>)
170:       <span class="ruby-identifier">dispatcher_log</span> <span class="ruby-identifier">:info</span>, <span class="ruby-value str">&quot;asked to restart ASAP&quot;</span>
171:       <span class="ruby-ivar">@when_ready</span> = <span class="ruby-identifier">:restart</span>
172:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000047" class="method-detail">
        <a name="M000047"></a>

        <div class="method-heading">
          <a href="#M000047" class="method-signature">
          <span class="method-name">restore!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000047-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 201</span>
201:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore!</span>
202:       <span class="ruby-identifier">$&quot;</span>.<span class="ruby-identifier">replace</span> <span class="ruby-ivar">@features</span>
203:       <span class="ruby-constant">Dispatcher</span>.<span class="ruby-identifier">reset_application!</span>
204:       <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Routing</span><span class="ruby-operator">::</span><span class="ruby-constant">Routes</span>.<span class="ruby-identifier">reload</span>
205:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000048" class="method-detail">
        <a name="M000048"></a>

        <div class="method-heading">
          <a href="#M000048" class="method-signature">
          <span class="method-name">run_gc!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000048-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 207</span>
207:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run_gc!</span>
208:       <span class="ruby-ivar">@gc_request_countdown</span> = <span class="ruby-identifier">gc_request_period</span>
209:       <span class="ruby-constant">GC</span>.<span class="ruby-identifier">enable</span>; <span class="ruby-constant">GC</span>.<span class="ruby-identifier">start</span>; <span class="ruby-constant">GC</span>.<span class="ruby-identifier">disable</span>
210:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">with_signal_handler</span><span class="method-args">(signal) {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/fcgi_handler.rb, line 147</span>
147:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_signal_handler</span>(<span class="ruby-identifier">signal</span>)
148:       <span class="ruby-identifier">install_signal_handler</span>(<span class="ruby-identifier">signal</span>)
149:       <span class="ruby-keyword kw">yield</span>
150:     <span class="ruby-keyword kw">ensure</span>
151:       <span class="ruby-identifier">install_signal_handler</span>(<span class="ruby-identifier">signal</span>, <span class="ruby-value str">'DEFAULT'</span>)
152:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>